package cn.iocoder.yudao.module.system.util.enums;

import com.trs.hybase.client.TRSDatabaseColumn;

/**
 * 字段对应海贝字段类型
 */
public enum HybaseFieldType {

    k_str("string", TRSDatabaseColumn.TYPE_PHRASE),
    k_char("varchar", TRSDatabaseColumn.TYPE_CHAR),
    k_int("number", TRSDatabaseColumn.TYPE_NUMBER),
    k_number("integer", TRSDatabaseColumn.TYPE_NUMBER),
    k_smallint("smallint", TRSDatabaseColumn.TYPE_NUMBER),
    k_bigint("bigint", TRSDatabaseColumn.TYPE_NUMBER),
    k_date("date", TRSDatabaseColumn.TYPE_DATE),
    k_datetime("datetime", TRSDatabaseColumn.TYPE_DATE),
    k_clob("text", TRSDatabaseColumn.TYPE_DOCUMENT),
    k_attach("file", TRSDatabaseColumn.TYPE_PHRASE),
    k_image("image", TRSDatabaseColumn.TYPE_PHRASE),
    k_video("video", TRSDatabaseColumn.TYPE_PHRASE),
    k_audio("audio", TRSDatabaseColumn.TYPE_PHRASE),
    k_know_system("knowSystem", TRSDatabaseColumn.TYPE_CHAR);

    private String fieldType;

    private Integer hybaseType;

    HybaseFieldType(String fieldType, Integer hybaseType){
        this.fieldType = fieldType;
        this.hybaseType = hybaseType;
    }

    public static Integer getDbType(String fieldType) {
        for (HybaseFieldType hybaseFieldType : HybaseFieldType.values()) {
            if (hybaseFieldType.fieldType.equals(fieldType)) {
                return hybaseFieldType.hybaseType;
            }
        }
        return TRSDatabaseColumn.TYPE_PHRASE;
    }
}
